define(function (require, exports, module) {
    'use strict';
    var api = require("config");
    var userList = require('user/userList');
    var roleMain = require('user/roleMain');
    var managment = require('cpy/managment');
    var channelMain = require('cpy/channelMain');
    var channelServe = require('cpy/channelServe');
    var actionLogs = require('text/actionLogs');
    var interfaceLogs = require('text/interfaceLogs');
    var customerInf = require('only/customerInf');
    var faceFeature = require('face/faceFeature');
    var faceLibrary = require('face/faceLibrary');
    var Finger = require('face/Finger');
    var library = require('face/library')
    var obb = {
        "/userMain": userList,
        "/roleMain":roleMain,
        "/managment":managment,
        "/channelMain":channelMain,
        "/channelServe":channelServe,
        "/actionLogs":actionLogs,
        "/interfaceLogs":interfaceLogs,
        "/customerInf":customerInf,
        "/faceFeature":faceFeature,
        "/faceLibrary":faceLibrary,
        "/Finger":Finger,
        "/library":library
    };// key 值 转换
    var menuobb = {
        "/userMain": './view/user/userList.html',
        "/roleMain":'./view/user/roleMain.html',
        "/managment":'./view/cpy/managment.html',
        "/channelMain":'./view/cpy/channelMain.html',
        "/channelServe":'./view/cpy/channelServe.html',
        "/actionLogs":'./view/text/actionLogs.html',
        "/interfaceLogs":'./view/text/interfaceLogs.html',
        "/customerInf":'./view/only/customerInf.html',
        "/faceFeature":'./view/face/faceFeature.html',
        "/faceLibrary":'./view/face/faceLibrary.html',
        "/Finger":'./view/face/Finger.html',
        "/library":'./view/face//library.html'
    }; // url 转换
    var data = [];
    var str = "";
    var viewModel= {
        UserList: ko.observableArray(data),
        details:ko.observable()
    };
    ko.applyBindings(viewModel);
    var obj = {
        init: function () {
            this.getMenuList()
        },
        getMenuList:function () {
            jQuery.support.cors = true;
            $.ajax({
                type: 'post',
                url: api + 'bfm-admin/deploy/generateRoleMenu',
                contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json',
                data: {
                    loginName: $.cookie('hxcookies')
                },
                success: function (res) {
                    viewModel.UserList(res.rows);
                    viewModel.details("<img src='./image/right.png'>");
                    $(".menu-item-next-child").bind('click', function (event) {
                        if($(this).attr('type')==='0'){
                            $(".menu-item-next-child").removeClass('active');
                            $(this).addClass('active')
                            var path = $(this).attr('path');
                            $("#content").load(menuobb[path], obb[path].init());
                        }
                        else{
                           $(".menu-item-next-last").hide();
                           $(this).next('.menu-item-next-last').show();
                        }

                    });
                    $(".menu-item-next-childs").bind('click', function (event) {

                            $(".menu-item-next-child").removeClass('active');
                            $(".menu-item-next-childs").removeClass('active');
                            $(this).addClass('active')
                            var path = $(this).attr('path');
                            $("#content").load(menuobb[path], obb[path].init());

                    });
                    $('.menu-item-child').bind('click', function () {
                        $('.downBtn').attr('src','./image/right.png');

                        $(".menu-item-next").hide();
                        $(".menu-item").eq(Number($(this).attr('index'))).children('.menu-item-next').show();
                        $(this).children('.downBtn').attr('src','./image/down.png');
                    });
                },
                error: function (res) {
                    console.log('error')
                }
            })
        }
    };
    module.exports = obj;
});